using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace Dark_Dungeon
{
    public class MainGame : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        GameEngine gameEngine;

        public MainGame()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }

        protected override void Initialize()
        {
            //Configurar caracteristicas de pantalla
            graphics.PreferredBackBufferWidth = Config.ResolutionWidth;
            graphics.PreferredBackBufferHeight = Config.ResolutionHeight;
            graphics.IsFullScreen = Config.FullScreen;
            graphics.ApplyChanges();

            base.Initialize();
        }

        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            try
            {
                gameEngine = new GameEngine(this);
                this.Components.Add(gameEngine);
            }
            catch (Exception ex)
            {
                Debug.AddStaticText(ex.Message);
            }
        }

        protected override void UnloadContent()
        {

        }

        protected override void Update(GameTime gameTime)
        {
            if (Controls.checkKey(Keys.Escape))
                Exit();

            base.Update(gameTime);
        }

        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);


            base.Draw(gameTime);

            // Textos del debug
            if (Config.Debug)
                Debug.Draw(gameTime, spriteBatch);

        }
    }
}
